#region Copyright
/// <copyright>
/// Copyright (c) 2008 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using Osh.Epg;

namespace Osh.Media
{
	public abstract class ChannelBase : MediaBase, IChannel
	{
		private IAudioStream _currentAudio;
		private IVideoStream _currentVideo;
		private ISubtitleStream _currentSubtitles;
		private AudioStreamCollection _audioStreams;
		private VideoStreamCollection _videoStreams;
		private SubtitleStreamCollection _subtitleStreams;

		protected ChannelBase()
		{
		}

		public ChannelBase(IMediaLibrary library, Uri uri)
			: base(library, uri)
		{
		}

		#region IChannel
		public virtual int? ChannelNumber
		{
			get { return (int?)this.Attributes[MediaAttributeNames.ChannelNumber]; }
			protected set { this.Attributes[MediaAttributeNames.ChannelNumber] = value; }
		}

		public virtual IAudioStream CurrentAudio
		{
			get { return _currentAudio; }
			protected set { _currentAudio = value; }
		}

		public virtual IVideoStream CurrentVideo
		{
			get { return _currentVideo; }
			protected set { _currentVideo = value; }
		}

		public virtual ISubtitleStream CurrentSubtitles
		{
			get { return _currentSubtitles; }
			protected set { _currentSubtitles = value; }
		}

		public virtual AudioStreamCollection AudioStreams
		{
			get
			{
				if(_audioStreams == null)
					_audioStreams = new AudioStreamCollection();
				return _audioStreams;
			}
			protected set { _audioStreams = value; }
		}

		public virtual VideoStreamCollection VideoStreams
		{
			get
			{
				if(_videoStreams == null)
					_videoStreams = new VideoStreamCollection();
				return _videoStreams;
			}
			protected set { _videoStreams = value; }
		}

		public virtual SubtitleStreamCollection SubtitleStreams
		{
			get
			{
				if(_subtitleStreams == null)
					_subtitleStreams = new SubtitleStreamCollection();
				return _subtitleStreams;
			}
			protected set { _subtitleStreams = value; }
		}

		public virtual ChannelEpg GetEpg(DateTime startTime, DateTime endTime)
		{
			return new ChannelEpg(startTime, endTime);
		}
		#endregion IChannel
	}
}
